package com.example.myapplication.tack_30.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.myapplication.R;
import com.example.myapplication.utils.OkHttpTool;


public class PersonFragment extends Fragment {
    private View view;
    private TextView username;
    private SharedPreferences sharedPreferences;
    private String name;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.tack_30_fragment_person2, container, false);
        init();
        return view;
    }

    private void init() {
        username = view.findViewById(R.id.username);
        sharedPreferences = getActivity().getSharedPreferences("login", Context.MODE_PRIVATE);
        name = sharedPreferences.getString("username", "");
        if(OkHttpTool.TOKEN != null){
            username.setText(name);
        }else {
            username.setText("未登录");
        }
    }
}